<template>
	<view class="content">
		<uamhead :title="title"></uamhead>
		<view class="Tosearch" @click="Tosearch">
			<searchHot></searchHot>
		</view>
		
		<scroll-view scroll-y="true">
			<view>
				<m-for-skeleton :avatarSize="200" :row="3" :title="false" :loading="loading" isarc="square"
					:titleStyle="{}" v-for="(item,key) in 4" :key="key">
				</m-for-skeleton>
			</view>
			<view class="index-list" v-for="(item,index) in playlist" :key="index" @click="handleToList(item.id)">
				<view class="index-list-item">
					<view class="index-list-img">
						<image :src="item.coverImgUrl" mode=""></image>
						<text>{{item.updateFrequency}}</text>
					</view>
					<view class="index-list-text">
						<view v-for="(musicItem,index) in item.tracks" :key="index">
							{{index+1}}.{{musicItem.first}}-{{musicItem.second}}
						</view>
					</view>
				</view>
			</view>

		</scroll-view>
	</view>
</template>

<script>
	import {
		topList
	} from '../../common/api.js'
	// const toplistdata=require('@/static/toplist.json')
	import mForSkeleton from "@/components/m-for-skeleton/m-for-skeleton";
	import uamhead from "../../components/uamhead/uamhead.vue"
	import searchHot from "../../components/searchHot/searchHot.vue"
	export default {
		components: {
			mForSkeleton,
			searchHot
		},
		data() {
			return {
				playlist: [],
				title: 'UAMusic',
				loading: true
			}
		},
		onLoad() {
			// this.playlist= toplistdata;
			topList().then((res) => {
				if (res.length) {
					setTimeout(() => {
						this.playlist = res;
						this.loading = false
					}, 2000);
				}
			});
		},
		methods: {
			handleToList(id) {
				uni.navigateTo({
					url: '/pages/list/list?id=' + id
				})
			},
			Tosearch(){
				uni.navigateTo({
					url:"../search/search"
				})
			}
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		justify-content: center;
	}
	
	.Tosearch{
		display: block;
		float: right;
	}
	
	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}

	.index-list {
		margin: 0 30rpx;
		width: 95%
	}

	.index-list-item {
		display: flex;
		margin-bottom: 35rpx;
	}

	.index-list-img {
		width: 212rpx;
		height: 212rpx;
		margin-right: 20rpx;
		border-radius: 15rpx;
		overflow: hidden;
		position: relative;
	}

	.index-list-img image {
		width: 100%;
		height: 100%;
	}

	.index-list-img text {
		position: absolute;
		font-size: 22rpx;
		color: white;
		bottom: 15rpx;
		left: 15rpx;
	}

	.index-list-text {
		flex: 1;
		font-size: 24rpx;
		line-height: 68rpx;
	}

	.index-list-text view {}
</style>
